import 'package:kepu/generated/json/base/json_convert_content.dart';
import 'package:kepu/model/common_list_page_entity.dart';

CommonListPageEntity $CommonListPageEntityFromJson(Map<String, dynamic> json) {
  final CommonListPageEntity commonListPageEntity = CommonListPageEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    commonListPageEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    commonListPageEntity.msg = msg;
  }
  final CommonListPageData? data = jsonConvert.convert<CommonListPageData>(
      json['data']);
  if (data != null) {
    commonListPageEntity.data = data;
  }
  return commonListPageEntity;
}

Map<String, dynamic> $CommonListPageEntityToJson(CommonListPageEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.toJson();
  return data;
}

extension CommonListPageEntityExtension on CommonListPageEntity {
  CommonListPageEntity copyWith({
    int? code,
    String? msg,
    CommonListPageData? data,
  }) {
    return CommonListPageEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

CommonListPageData $CommonListPageDataFromJson(Map<String, dynamic> json) {
  final CommonListPageData commonListPageData = CommonListPageData();
  final List<CommonListPageDataRecords>? records = (json['records'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<CommonListPageDataRecords>(
          e) as CommonListPageDataRecords).toList();
  if (records != null) {
    commonListPageData.records = records;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    commonListPageData.total = total;
  }
  final int? size = jsonConvert.convert<int>(json['size']);
  if (size != null) {
    commonListPageData.size = size;
  }
  final int? current = jsonConvert.convert<int>(json['current']);
  if (current != null) {
    commonListPageData.current = current;
  }
  final int? pages = jsonConvert.convert<int>(json['pages']);
  if (pages != null) {
    commonListPageData.pages = pages;
  }
  return commonListPageData;
}

Map<String, dynamic> $CommonListPageDataToJson(CommonListPageData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['records'] = entity.records.map((v) => v.toJson()).toList();
  data['total'] = entity.total;
  data['size'] = entity.size;
  data['current'] = entity.current;
  data['pages'] = entity.pages;
  return data;
}

extension CommonListPageDataExtension on CommonListPageData {
  CommonListPageData copyWith({
    List<CommonListPageDataRecords>? records,
    int? total,
    int? size,
    int? current,
    int? pages,
  }) {
    return CommonListPageData()
      ..records = records ?? this.records
      ..total = total ?? this.total
      ..size = size ?? this.size
      ..current = current ?? this.current
      ..pages = pages ?? this.pages;
  }
}

CommonListPageDataRecords $CommonListPageDataRecordsFromJson(
    Map<String, dynamic> json) {
  final CommonListPageDataRecords commonListPageDataRecords = CommonListPageDataRecords();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    commonListPageDataRecords.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    commonListPageDataRecords.name = name;
  }
  final String? image = jsonConvert.convert<String>(json['image']);
  if (image != null) {
    commonListPageDataRecords.image = image;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    commonListPageDataRecords.description = description;
  }
  final String? region = jsonConvert.convert<String>(json['region']);
  if (region != null) {
    commonListPageDataRecords.region = region;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    commonListPageDataRecords.type = type;
  }
  return commonListPageDataRecords;
}

Map<String, dynamic> $CommonListPageDataRecordsToJson(
    CommonListPageDataRecords entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['image'] = entity.image;
  data['description'] = entity.description;
  data['region'] = entity.region;
  data['type'] = entity.type;
  return data;
}

extension CommonListPageDataRecordsExtension on CommonListPageDataRecords {
  CommonListPageDataRecords copyWith({
    int? id,
    String? name,
    String? image,
    String? description,
    String? region,
    String? type,
  }) {
    return CommonListPageDataRecords()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..image = image ?? this.image
      ..description = description ?? this.description
      ..region = region ?? this.region
      ..type = type ?? this.type;
  }
}